package com.zyp.servlet;

import com.zyp.bean.Student;
import com.zyp.factory.StudentDaoFatory;
import com.zyp.service.StudentService;
import com.zyp.service.UserService;
import com.zyp.tool.Tool;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;

@WebServlet(name = "addServlet", urlPatterns = "/addServlet")
public class addServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
//        获取到值
        Object[] objects = Tool.GetValue(request);

        //执行sql，判断是否插入成功
        StudentService studentService = new StudentService();
        int whether = studentService.getStudetService(objects);

        if (whether==1){

        }else{

        }

        response.sendRedirect("http://localhost:8081/task_4module_1/add.jsp");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
